package com.cntcdt.api.db.dao;

import java.util.List;

import com.cntcdt.api.db.dao.base.UpdateLogDaoBase;
import com.cntcdt.api.db.model.UpdateLogModel;

/**
 * 这是cdt_update_log的Dao实现类
 */
public class UpdateLogDao extends UpdateLogDaoBase   {
    /**
     * UpdateLogDao对象
     */
    private static UpdateLogDao instance = new UpdateLogDao();

    /**
     * 默认构造方法
     */
    private UpdateLogDao() {
    }

    /**
     * 获得对象实例
     */
    public static UpdateLogDao getInstance() { 
         return instance;
    } 
    
    public List<UpdateLogModel> findBySortTime(int sortTime) {
    	sortTime = sortTime*20;
        String sql = "SELECT * FROM " + TABLE + " order by addTime desc limit ?,20";
       Object[] paramObjs = {sortTime};
       List<UpdateLogModel > modelList = this.queryModelList(sql, paramObjs);
       return modelList;
   }
    
    public UpdateLogModel findBytaskId(int taskId) {
        String sql = "SELECT * FROM " + TABLE + " WHERE taskId = ?";
       Object[] paramObjs = {taskId};
       List<UpdateLogModel > modelList = this.queryModelList(sql, paramObjs);
       if(modelList != null && modelList.size() > 0){ 
             return  modelList.get(0);
       } 
       return null;
   }   
    
    public List<UpdateLogModel> findBySortTime(int sortTime, String terminal) {
    	sortTime = sortTime*20;
        String sql = "SELECT * FROM " + TABLE + " where terminal = ? order by addTime desc limit ?,20";
       Object[] paramObjs = {terminal,sortTime};
       List<UpdateLogModel > modelList = this.queryModelList(sql, paramObjs);
       return modelList;
   }    
}
